<template>
  <div class="dashboard-container">
    <el-card class="welcome-card">
      <template #header>
        <div class="card-header">
          <span>欢迎使用后台管理系统</span>
        </div>
      </template>
      <div class="welcome-content">
        <p>这是一个基于Vue3、Vite、Vue Router、Pinia和Element Plus构建的后台管理系统。</p>
        <p>系统支持多种布局模式：垂直布局、水平布局和混合布局。</p>
        <p>您可以通过顶部工具栏切换主题、布局、全屏模式等。</p>
      </div>
    </el-card>

    <div class="stats-container">
      <el-card class="stat-card" v-for="stat in stats" :key="stat.id">
        <div class="stat-content">
          <div class="stat-value">{{ stat.value }}</div>
          <div class="stat-label">{{ stat.label }}</div>
        </div>
        <div class="stat-icon"><el-icon :component="stat.icon" /></div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import {
  User, Menu, Lock, Monitor
} from '@element-plus/icons-vue'

// 统计数据
const stats = ref([
  {
    id: 1,
    value: '1,234',
    label: '总用户数',
    icon: User
  },
  {
    id: 2,
    value: '56',
    label: '菜单数量',
    icon: Menu
  },
  {
    id: 3,
    value: '8',
    label: '权限组',
    icon: Lock
  },
  {
    id: 4,
    value: '100%',
    label: '系统可用率',
    icon: Monitor
  }
])
</script>

<style scoped lang="scss">
.dashboard-container {
  padding: 20px;
}

.welcome-card {
  margin-bottom: 20px;

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .welcome-content {
    padding: 20px 0;

    p {
      margin-bottom: 10px;
      line-height: 1.6;
    }
  }
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;

  .stat-content {
    .stat-value {
      font-size: 24px;
      font-weight: bold;
      margin-bottom: 5px;
    }

    .stat-label {
      color: #666;
    }
  }

  .stat-icon {
    font-size: 32px;
    color: #1890ff;
  }
}

// 暗色模式适配
.dark {
  .welcome-card,
  .stat-card {
    background-color: #2c2c2c;
    color: #fff;
  }

  .stat-label {
    color: #ccc;
  }
}
</style>